<?php
if (!defined('APPPATH')) exit('No direct script access allowed');

include_once(APPPATH.'libraries/api/core/MySQL.php');
include_once(APPPATH.'libraries/api/core/Services.php');

class MenuType extends Services {

	public static function menuTypeGet($menu_type_id) {
		if(parent::checkArguments($menu_type_id)) {
			$query = "SELECT `menu_type_id`, `name`, `title`, `description` FROM `menu_type` WHERE `menu_type_id` = $menu_type_id; ";
			$result = MySQL::selectGetRow($query);
			if(parent::check($result)) {
				return $result;
			} else {
				return array();
			}
		} else {
			return array();
		}
	}

	public static function menuTypeSet($name, $title, $description) {
		if(parent::checkArguments(array($name, $title, $description))) {
			$query = "INSERT INTO `menu_type` (`name`, `title`, `description`) VALUES ('$name', '$title', '$description'); ";
			$result = MySQL::update($query);
			if(parent::check($result)) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}
	
	public static function menuTypesList() {
		$query = "SELECT `menu_type_id`, `name`, `title`, `description` FROM `menu_type`; ";
		$result = MySQL::selectGetArray($query);
		if(parent::check($result)) {
			return $result;
		} else {
			return array();
		}
	}

}

?>
